import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import './style.css'

// 路由配置
import Index from './views/Index.vue'
import Farm3D from './views/Farm3D.vue'
import Dashboard from './views/Dashboard.vue'
import CropManagement from './views/CropManagement.vue'
import EnvironmentMonitor from './views/EnvironmentMonitor.vue'
import AlertCenter from './views/AlertCenter.vue'
import AIPlantingPlan from './views/AIPlantingPlan.vue'

const routes = [
  {
    path: '/',
    component: Index,
    children: [
      { path: '', redirect: '/farm' },
      { path: 'farm', component: Farm3D },
      { path: 'dashboard', component: Dashboard },
      { path: 'crops', component: CropManagement },
      { path: 'environment', component: EnvironmentMonitor },
      { path: 'alerts', component: AlertCenter },
      { path: 'ai-plan', component: AIPlantingPlan }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

const app = createApp(App)

// 注册Element Plus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.use(router)
app.use(ElementPlus)
app.mount('#app')
